package com.hncu.Test;

public class Demo4 {//用String拼接字符串
    //String加数字是直接连接，数字不用打引号
    public static void main(String[] args) {
        int[] arr = {1,2,3};
        String a = "abc";
        a = a+5;//abc5
        System.out.println(a);
        System.out.println(splicing(arr));
    }
    public static String splicing(int[]arr){
        String s = "";
        s+="[";
        for (int i = 0;i<arr.length;i++){
            if (i==arr.length-1){//最后一位不需要逗号
                s+=arr[i];
            }
            else {
                s+= arr[i]+",";
            }
        }
        s+="]";
        return s;//返回
    }
}
